package com.hlhj.carview.adapter

import android.content.Context
import android.support.v4.view.PagerAdapter
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.bumptech.glide.Glide
import com.hlhj.carview.R
import com.hlhj.carview.bean.CarInfoBean
import com.hlhj.carview.http.Urls
import kotlinx.android.synthetic.main.car_img_pager_item.view.*

/**
 * Created by Never Fear   on 2018\12\21 0021.
Never More....
 */
class CarimgPagerAdp(private val context: Context,private val datas:ArrayList<CarInfoBean.Data>) :PagerAdapter() {

    override fun isViewFromObject(view: View, `object`: Any): Boolean {
        return view==`object`
    }

    override fun destroyItem(container: ViewGroup, position: Int, `object`: Any) {
//        super.destroyItem(container, position, `object`)
    }
    override fun instantiateItem(container: ViewGroup, position: Int): Any {
        val view = LayoutInflater.from(context).inflate(R.layout.car_img_pager_item, null)
        Glide.with(context).load(datas[position].img).into(view.itemImg)

        container?.addView(view)
        return view
    }
    override fun getCount(): Int {
        return datas.size
    }
}